 package tools.packet;

 import client.MapleClient;
 import handling.opcode.MtsOpcode;
 import handling.opcode.SendPacketOpcode;
 import server.MTSItemsInfo;
 import tools.data.output.MaplePacketLittleEndianWriter;




 public class MTSPacket
 {
   public static byte[] startMTS(MapleClient c) {
/*  15 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
/*  16 */     mplew.writeShort(SendPacketOpcode.MTS_OPEN.getValue());
/*  17 */     PacketHelper.addCharacterInfo(mplew, c.getPlayer(), -1L);
/*  18 */     mplew.writeLong(PacketHelper.getTime(System.currentTimeMillis()));

/*  20 */     return mplew.getPacket();
   }




   public static byte[] MTSInfo(int type, MapleClient c, MTSItemsInfo MtsOperation) {
/*  27 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  29 */     mplew.writeShort(SendPacketOpcode.MTS_OPERATION.getValue());
/*  30 */     mplew.writeInt(type);
/*  31 */     mplew.writeInt((type == MtsOpcode.首页搜索.getValue() || type == MtsOpcode.行情搜索.getValue()) ? 1000 : 0);
/*  32 */     mplew.writeInt(0);
/*  33 */     if (type == MtsOpcode.首页搜索.getValue() || type == MtsOpcode.行情搜索.getValue()) {
/*  34 */       mplew.writeShort(1);
     }
/*  36 */     mplew.writeInt(MtsOperation.Mtsitems().size());
/*  37 */     for (MTSItemsInfo mtsitem : MtsOperation.Mtsitems()) {




/*  42 */       mplew.writeInt(mtsitem.getId());
/*  43 */       mplew.writeInt(0);
/*  44 */       mplew.writeInt(mtsitem.getAccid());
/*  45 */       mplew.writeInt(mtsitem.getCid());
/*  46 */       mplew.writeInt((type == MtsOpcode.行情搜索.getValue()) ? 3 : mtsitem.getResult());
/*  47 */       mplew.writeInt((type == MtsOpcode.行情搜索.getValue()) ? 0 : 120);
/*  48 */       mplew.writeAsciiString(mtsitem.getOwner(), 13);
/*  49 */       mplew.writeLong((type == MtsOpcode.行情搜索.getValue()) ? mtsitem.getPrice() : 0L);
/*  50 */       mplew.writeLong((type == MtsOpcode.行情搜索.getValue()) ? 0L : -1L);
/*  51 */       mplew.writeLong(mtsitem.getTotalPrice());
/*  52 */       mplew.writeLong(mtsitem.getPrice());

/*  54 */       mplew.writeLong(PacketHelper.getTime(mtsitem.getExpiredate()));
/*  55 */       if (type == MtsOpcode.行情搜索.getValue()) {
/*  56 */         mplew.writeInt(mtsitem.getOther_id());
/*  57 */         mplew.writeAsciiString(mtsitem.getOther(), 13);
       } else {
/*  59 */         mplew.writeInt(0);
/*  60 */         mplew.writeZeroBytes(13);
       }
/*  62 */       mplew.writeInt(-1);
/*  63 */       mplew.writeLong(0L);
/*  64 */       mplew.writeLong(PacketHelper.getTime(mtsitem.getStartdate()));
/*  65 */       mplew.writeLong(0L);
/*  66 */       mplew.writeLong(0L);
/*  67 */       mplew.writeLong((type == MtsOpcode.行情搜索.getValue()) ? PacketHelper.getTime(mtsitem.getDonedate()) : PacketHelper.getTime(-2L));
/*  68 */       mplew.writeInt(1);
/*  69 */       PacketHelper.addItemInfo(mplew, mtsitem.getSpItem());
     }


/*  73 */     return mplew.getPacket();
   }




   public static byte[] MTSDoneInfo(int type, MapleClient c, MTSItemsInfo MtsOperation) {
/*  80 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  82 */     mplew.writeShort(SendPacketOpcode.MTS_OPERATION.getValue());
/*  83 */     mplew.writeInt(type);
/*  84 */     mplew.writeInt(0);
/*  85 */     mplew.writeInt(0);
/*  86 */     mplew.writeInt(MtsOperation.Mtsitems().size());
/*  87 */     for (MTSItemsInfo mtsitem : MtsOperation.Mtsitems())
     {











































/* 132 */       DoneInfo(c, mplew, mtsitem);
     }
/* 134 */     return mplew.getPacket();
   }







   public static byte[] BuySuccess(int type, int show, MTSItemsInfo mtsitem, boolean update) {
/* 144 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 146 */     mplew.writeShort(SendPacketOpcode.MTS_OPERATION.getValue());

/* 148 */     mplew.writeInt(type);
/* 149 */     mplew.writeInt(show);
/* 150 */     mplew.writeInt(mtsitem.getId());
/* 151 */     mplew.writeBool(update);
/* 152 */     if (update) {
/* 153 */       mplew.writeInt(mtsitem.getId());
/* 154 */       mplew.writeInt(0);
/* 155 */       mplew.writeInt(mtsitem.getAccid());
/* 156 */       mplew.writeInt(mtsitem.getCid());
/* 157 */       mplew.writeInt((type == MtsOpcode.更新状态.getValue() || type == MtsOpcode.更新道具数量状态.getValue()) ? 0 : mtsitem.getResult());
/* 158 */       mplew.writeInt(120);
/* 159 */       mplew.writeAsciiString(mtsitem.getOwner(), 13);
/* 160 */       mplew.writeLong(0L);
/* 161 */       mplew.writeLong(-1L);
/* 162 */       mplew.writeLong(mtsitem.getTotalPrice());
/* 163 */       mplew.writeLong(mtsitem.getPrice());
/* 164 */       mplew.writeLong(PacketHelper.getTime(mtsitem.getExpiredate()));
/* 165 */       mplew.writeInt(0);
/* 166 */       mplew.writeZeroBytes(13);
/* 167 */       mplew.writeInt(-1);
/* 168 */       mplew.writeLong(0L);
/* 169 */       mplew.writeLong(PacketHelper.getTime(mtsitem.getStartdate()));
/* 170 */       mplew.writeLong(0L);
/* 171 */       mplew.writeInt(0);
/* 172 */       mplew.writeInt(0);
/* 173 */       mplew.writeLong(PacketHelper.getTime(-2L));
/* 174 */       mplew.writeInt(1);
/* 175 */       PacketHelper.addItemInfo(mplew, mtsitem.getSpItem());
     }
/* 177 */     return mplew.getPacket();
   }


   private static void MtsItemInfo(int type, MTSItemsInfo MtsOperation, MaplePacketLittleEndianWriter mplew) {
/* 182 */     for (MTSItemsInfo mtsitem : MtsOperation.Mtsitems()) {
/* 183 */       if (type == MtsOpcode.首页搜索.getValue() || type == MtsOpcode.行情搜索.getValue()) {
/* 184 */         mplew.write(1);
       }
/* 186 */       mplew.writeInt(mtsitem.getId());
/* 187 */       mplew.writeInt(0);
/* 188 */       mplew.writeInt(mtsitem.getAccid());
/* 189 */       mplew.writeInt(mtsitem.getCid());
/* 190 */       mplew.writeInt(mtsitem.getResult());
/* 191 */       mplew.writeInt((type == MtsOpcode.行情搜索.getValue()) ? 0 : 120);
/* 192 */       mplew.writeAsciiString(mtsitem.getOwner(), 13);
/* 193 */       mplew.writeLong((type == MtsOpcode.行情搜索.getValue()) ? mtsitem.getPrice() : 0L);
/* 194 */       mplew.writeLong((type == MtsOpcode.行情搜索.getValue()) ? 0L : -1L);
/* 195 */       mplew.writeLong(mtsitem.getPrice());
/* 196 */       mplew.writeLong(PacketHelper.getTime(mtsitem.getExpiredate()));
/* 197 */       if (type == MtsOpcode.行情搜索.getValue()) {
/* 198 */         mplew.writeInt(mtsitem.getOther_id());
/* 199 */         mplew.writeAsciiString(mtsitem.getOther(), 13);
       } else {
/* 201 */         mplew.writeInt(0);
/* 202 */         mplew.writeZeroBytes(13);
       }
/* 204 */       mplew.writeInt(-1);
/* 205 */       mplew.writeLong(0L);
/* 206 */       mplew.writeLong(PacketHelper.getTime(mtsitem.getStartdate()));
/* 207 */       mplew.writeLong(0L);
/* 208 */       mplew.writeLong(0L);
/* 209 */       mplew.writeLong((type == MtsOpcode.行情搜索.getValue()) ? PacketHelper.getTime(mtsitem.getDonedate()) : PacketHelper.getTime(-2L));
/* 210 */       mplew.writeInt(1);
/* 211 */       PacketHelper.addItemInfo(mplew, mtsitem.getSpItem());
     }
   }





   public static byte[] AuctionMessage(int type) {
/* 220 */     return AuctionMessage(type, 0, 0);
   }

   public static byte[] AuctionMessage(int type, int show, int invid) {
/* 224 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 226 */     mplew.writeShort(SendPacketOpcode.MTS_OPERATION.getValue());

/* 228 */     mplew.writeInt(type);
/* 229 */     mplew.writeInt(show);
/* 230 */     mplew.writeInt(invid);

/* 232 */     return mplew.getPacket();
   }


   public static void DoneInfo(MapleClient c, MaplePacketLittleEndianWriter mplew, MTSItemsInfo mtsitem) {
/* 237 */     mplew.writeInt(mtsitem.getId());
/* 238 */     mplew.writeInt(0);
/* 239 */     mplew.writeInt(mtsitem.getId());
/* 240 */     mplew.writeInt(c.getAccID());
/* 241 */     mplew.writeInt(mtsitem.getCharacter_id());
/* 242 */     mplew.writeInt(mtsitem.getSpItem().getItemId());
/* 243 */     mplew.writeInt(mtsitem.getState());
/* 244 */     mplew.writeLong(mtsitem.getTotalPrice());
/* 245 */     mplew.writeLong(PacketHelper.getTime(mtsitem.getDonedate()));
/* 246 */     mplew.writeLong(0L);
/* 247 */     mplew.writeInt(mtsitem.getBuyNumber());
/* 248 */     mplew.writeInt(120);
/* 249 */     mplew.writeInt(1);
/* 250 */     boolean on = true;
/* 251 */     if (mtsitem.getState() == 3 || mtsitem.getState() == 7 || mtsitem.getState() == 8 || mtsitem.getState() == 9) {
/* 252 */       on = false;
     }
/* 254 */     mplew.writeBool(on);
/* 255 */     if (on) {
/* 256 */       mplew.writeInt(mtsitem.getId());
/* 257 */       mplew.writeInt(0);
/* 258 */       mplew.writeInt(mtsitem.getAccid());
/* 259 */       mplew.writeInt(mtsitem.getCid());
/* 260 */       mplew.writeInt(mtsitem.getResult());
/* 261 */       mplew.writeInt(120);
/* 262 */       mplew.writeAsciiString(mtsitem.getOwner(), 13);
/* 263 */       mplew.writeLong(0L);
/* 264 */       mplew.writeLong(-1L);
/* 265 */       mplew.writeLong(mtsitem.getTotalPrice());
/* 266 */       mplew.writeLong(mtsitem.getPrice());
/* 267 */       mplew.writeLong(PacketHelper.getTime(mtsitem.getExpiredate()));
/* 268 */       mplew.writeInt(0);
/* 269 */       mplew.writeZeroBytes(13);
/* 270 */       mplew.writeInt(-1);
/* 271 */       mplew.writeLong(0L);
/* 272 */       mplew.writeLong(PacketHelper.getTime(mtsitem.getStartdate()));
/* 273 */       mplew.writeLong(0L);
/* 274 */       mplew.writeInt(2);
/* 275 */       mplew.writeInt(1);
/* 276 */       mplew.writeLong(PacketHelper.getTime(-2L));
/* 277 */       mplew.writeInt(1);
/* 278 */       PacketHelper.addItemInfo(mplew, mtsitem.getSpItem());
     }
   }
 }


/* Location:              C:\PGX\Server.jar!\tools\packet\MTSPacket.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */